MeshWatch Console — team server
===============================

Run the six MeshWatch products on one server and let your team use them from
their own browsers: one address, one sign-in per person, administrators and
read-only viewers, and an audit log of who changed what.

The desktop app is for one person at one computer. The team server receives,
polls, stores and alerts exactly the same way, keeps running when nobody is
signed in to the server, and shows the same screens in a browser — over HTTPS,
behind a username and password.

For several sites, MeshWatch AI collects what many consoles and products see
into one place. One site with a team: the team server is enough.

Start
-----
    sudo useradd --system --home /var/lib/meshwatch-console --create-home \
        --shell /usr/sbin/nologin meshwatch-console
    sudo cp "/opt/MeshWatch Console/meshwatch-console-server.service" /etc/systemd/system/
    sudo systemctl daemon-reload
    sudo systemctl enable --now meshwatch-console-server
    sudo journalctl -u meshwatch-console-server     # address and certificate fingerprint

The first administrator can only be created on the server itself:

    sudo -u meshwatch-console "/opt/MeshWatch Console/meshwatch-console-server" \
        --data-dir /var/lib/meshwatch-console --create-admin admin

Then open https://<this server>:8444/ and sign in. Your browser will warn that it
does not know the self-signed certificate; check that the fingerprint it shows
is the one in the log, then continue — or use --cert/--key with your own.

Accounts
--------
Administrators can change everything. Viewers can see every screen, search,
open reports and export, but cannot change settings, licences, monitored
devices or targets. The server enforces this, not the screen. Add people under
Accounts in the console, or on the server:

    S='/opt/MeshWatch Console/meshwatch-console-server'
    sudo -u meshwatch-console "$S" --data-dir /var/lib/meshwatch-console --add-user alex --role viewer
    sudo -u meshwatch-console "$S" --data-dir /var/lib/meshwatch-console --reset-password alex
    sudo -u meshwatch-console "$S" --data-dir /var/lib/meshwatch-console --list-users

(In Docker: docker exec -it meshwatch-console meshwatch-console-server --data-dir /data --add-user alex --role viewer)

Audit log
---------
Settings → Audit log (administrators) lists every change and every refused
attempt, including account changes: when, who, from where, which product,
what. What was typed — passwords, keys — is never recorded. The file is /var/lib/meshwatch-console/audit.jsonl. If it cannot
be written (disk full, permissions), the server refuses changes until it can;
reading keeps working.

PDF
---
PDF exports and reports are drawn by the same program in the background. On a
server without a display that needs a virtual one:

    sudo apt-get install -y xvfb            # Debian / Ubuntu
    sudo dnf install -y xorg-x11-server-Xvfb  # RHEL / Rocky / Alma / Fedora

Without it, PDF buttons say so; Markdown and CSV work regardless.

Ports
-----
Console 8444 (HTTPS). Syslog 1514 (UDP/TCP) and SNMP traps 1162 (UDP) are
unprivileged; point your devices at those, or change a product's port in its
settings to use 514 / 162.

DNS is port 53 — routers can only send DNS to 53 — so TrafficWatch listens on
53, and the service file grants the service user permission to bind it
(AmbientCapabilities). On Ubuntu and most systemd distributions,
systemd-resolved already holds 127.0.0.53:53 and TrafficWatch reports "Port 53
is already in use". Either uncomment Environment=TW_DNS_HOST=<this server's LAN
address> in the service file (the two then coexist), or set
DNSStubListener=no in /etc/systemd/resolved.conf and restart systemd-resolved.

In Docker, publish 53 on the server's LAN address if the host runs
systemd-resolved:  -p 192.168.1.10:53:53/udp -p 192.168.1.10:53:53/tcp
(TCP too: a large DNS answer is asked again over TCP.)

Licence agreement
-----------------
Nothing is monitored until the licence agreement (EULA.txt in this folder, also
https://meshwatch.app/terms) has been accepted: the service file starts with
--accept-eula, or an administrator accepts it in the console after signing in.

Moving from the desktop console
-------------------------------
Copy the "products" folder of the desktop console's data folder into
/var/lib/meshwatch-console/products while the service is stopped, and give it
to the meshwatch-console user (sudo chown -R meshwatch-console: ...).
History, devices, targets and rules come along. Licence keys and saved
passwords (SMTP, SSH, SNMP, the Central token) were encrypted for the desktop
computer and cannot be read on another machine: enter the Suite key again on
the console's Suite key page, and re-enter saved passwords where a product asks.
